package cn.tedu.storage.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/*
    1.接口上添加 @LocalTCC
    2.第一阶段方法上添加 @TwoPhaseBusinessAction，并指定两个二阶段的方法名
    3.三个方法添加 BusinessActionContext 参数
    4.第一阶段方法上添加业务数据参数
    5.需要向二阶段传递的业务数据参数，添加 @BusinessActionContextParameter
 */
@LocalTCC
public interface StorageTccAction {
    @TwoPhaseBusinessAction(name = "StorageTccAction")
    boolean prepare(BusinessActionContext ctx,
                    @BusinessActionContextParameter(paramName = "productId") Long productId,
                    @BusinessActionContextParameter(paramName = "count") Integer count);

    boolean commit(BusinessActionContext ctx);
    boolean rollback(BusinessActionContext ctx);
}
